@extends('admin')

@section('content')
    <div class="nav">
        <ul class="cc">
            <li class="current">
                <a href="{{url('admin/sys/base')}}">修改密码</a>
            </li>
        </ul>
    </div>

    <form action="{{url('admin/sys/base')}}" method="POST" class="J_ajaxForm">

        <input type="hidden" name="_token" value="{{ csrf_token() }}">
        <div class="h_a">修改基地</div>
        <div class="table_full">

            <table width="100%">
                <colgroup>
                    <col class="th">
                    <col>
                </colgroup>
                <tbody>
                <tr>
                    <th>基地相册</th>
                    <td>
                        <button type="button" href="javascript:;" id="pickfiles" class="pickfiles" title="选择上传文件">添加图片
                        </button>
                        </br>
                        @if($pics)
                            @foreach($pics as $item)
                                <div data-id="144class=&quot;edui-default&quot;"
                                     style="border:1px solid #d4d4d4;margin:15px;padding:10px;background:#fff;border-radius:5px;position: relative;width: 250px;height: 137px;">
                                    <label style="color:#000;position: absolute;top: 0px;right: 0px;width: 250px;text-align: right;background: #fff;line-height:20px;font-size: 15px;margin: 5px 0;padding-right: 10px;"
                                           onclick="$(this).parent().remove();">X</label>
                                    <img src="{{asset('/img/base-'.$item.'/250-137')}}">
                                    <input id="pic_input" name="pic['{{$item}}']" type="hidden" value="{{$item}}">
                                </div>
                            @endforeach
                        @endif
                    </td>
                </tr>
                <tr>
                    <th>基地简介</th>
                    <td>
                        <script id="container" name="content" type="text/plain">
                            {!! $vedio->val !!}
                        </script>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>

        <div class="btn_wrap">
            <div class="btn_wrap_pd">
                <button type="submit" class="btn btn_submit mr10 J_ajax_submit_btn">修改</button>
            </div>
        </div>
    </form>
@stop

@section('js')
    @parent
    @include('UEditor::head')
    <script src="{{ asset('js/plupload/plupload.full.min.js') }}"></script>
    <script>
        var ue = UE.getEditor('container', {
            initialFrameWidth: 600, initialFrameHeight: 300, autoHeightEnabled: false, toolbars: [
                ['source', 'undo', 'redo', 'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc'],
                ['link', 'simpleupload', 'insertimage']
            ]
        });
        ue.ready(function () {
            ue.execCommand('serverparam', '_token', GV.TOKEN);//此处为支持laravel5 csrf ,根据实际情况修改,目的就是设置 _token 值.
        });
    </script>
    <script>
        $(function () {
            var uploader = new plupload.Uploader({
                runtimes: 'html5,flash,silverlight,html4',
                browse_button: 'pickfiles', // you can pass in id...
                //container: document.getElementById('container'), // ... or DOM Element itself
                url: "{{ url('upimg') }}",
                filters: {
                    max_file_size: '5mb',
                    mime_types: [
                        {title: "Image files", extensions: "jpg,gif,png"}
                    ]
                },
                multi_selection: false,
                file_data_name: 'file',
                multipart_params: {'_token': '{{ csrf_token() }}', 'dir': 'base'},
                // Flash settings
                flash_swf_url: '{{ asset("js/plupload/Moxie.swf") }}',
                // Silverlight settings
                silverlight_xap_url: '{{ asset('js/plupload/Moxie.xap') }}',
                init: {
                    PostInit: function () {
                        return false;
                    },
                    FilesAdded: function (up, file) {
                        $('.up-pic img').attr('src', '{{ asset('images/loading.gif') }}');
                        uploader.start();
                    },
                    Error: function (up, err) {
                        tips(err.message);
                    },
                    FileUploaded: function (up, file, responseObj) {
                        var response = $.parseJSON(responseObj.response);
                        if (response.state == 'success') {
                            $('.pickfiles').parent().append('<div class="edui-default" style="border:1px solid #d4d4d4;margin:15px;padding:10px;background:#fff;border-radius:5px;position: relative;width: 250px;height: 137px;"><label style="color:#000;position: absolute;top: 0px;right: 0px;width: 250px;text-align: right;background: #fff;line-height:20px;font-size: 15px;margin: 5px 0;padding-right: 10px;" onclick="$(this).parent().remove();" >X</label> <img src="/img/base-' + response.id + '/250-137"/><input id="pic_input" name="pic['+response.id+']" type="hidden" value="'+response.id+'"></div>');
                        } else {
                            tips(response.message);
                        }
                    }
                }
            });
            uploader.init();
        });
    </script>
@stop
